package svc

import (
	"github.com/zeromicro/go-zero/core/stores/redis"
	"web_server/internal/config"
)

type ServiceContext struct {
	Config      config.Config
	RedisClient *redis.Redis
	MysqlClient MysqlModels
}

func NewServiceContext(c config.Config) *ServiceContext {
	// redis 连接
	redisClient := ConnectRedis(c.Redis)
	// mysql 连接 + 自动创建表
	mysqlClient := ConnectMysql(c.MySql)
	// 其他的初始化

	return &ServiceContext{
		Config:      c,
		RedisClient: redisClient,
		MysqlClient: mysqlClient,
	}
}
